package com.yidu.BusinessParament.mapper;

import com.yidu.BusinessParament.entity.Cash;
import com.yidu.BusinessParament.entity.Fund;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 现金账户持久层接口
 * @Version 1.0
 * @Author zsc
 * @Date 2022/12/8 14:20
 */
@Repository
@Mapper
public interface CashMapper {
    /**
     * 查询现金账户表
     * @param map map集合
     * @return
     */
    @Select("select * from cash where 1=1 ${strWhere} limit #{page},#{limit}")
    public List<Cash> SelectCash(Map map);

    /**
     * 分页查现金账户表行数 模糊查询后的行数
     * @param map map集合
     * @return
     */
    @Select("select count(*) from cash where 1=1 ${strWhere}")
    public int SelectCashCount(Map map);

    /**
     * 查询最大ID的方法
     * @return
     */
    @Select ("SELECT cashId FROM cash ORDER BY cashId  DESC LIMIT 1")
    public String SelectMaxCashId();

    /**
     * 增加现金账户数据
     * @param cash 现金账户对象
     * @return
     */
    @Insert ("insert into cash(cashId,bankId,accountName,bankName,stockpileType,cardRetes," +
            "bearingTime,openTime,endTime,Remark) values(#{cashId},#{bankId},#{accountName}," +
            "#{bankName},#{stockpileType},#{cardRetes},#{bearingTime},#{openTime},#{endTime},#{Remark})")
    public int InsertCash(Cash cash);

    /**
     * 删除现金账户数据
     * @param cashId 现金账户Id
     * @return
     */
    public int DeleteCash(List cashId);

    /**
     * 修改现金账户数据
     * @param cash 现金账户对象
     * @return
     */
    @Update ("update cash set bankId=#{bankId},accountName=#{accountName},bankName=#{bankName}," +
            "stockpileType=#{stockpileType},cardRetes=#{cardRetes},bearingTime=#{bearingTime}," +
            "openTime=#{openTime},endTime=#{endTime},Remark=#{Remark} where cashId=#{cashId}")
    public int UpdateCash(Cash cash);
}
